#include "heroplane.h"

heroplane::heroplane()
{
  m_plane.load(":/res/me2.png");

  m_X=(512-m_plane.width())*0.5;
  m_Y=768-m_plane.height();

  m_Rect.setWidth(m_plane.width());
   m_Rect.setHeight(m_plane.height());
   m_Rect.moveTo(m_X,m_Y);
}
void heroplane::shoot(){
    m_recorder++;
    if(m_recorder<30){
        return;
    }
    m_recorder=0;
    for(int i=0;i<30;i++){
        if(m_bullets[i].m_Free){
            m_bullets[i].m_Free=false;
            m_bullets[i].m_X=m_X+m_Rect.width()*0.5-10;
            m_bullets[i].m_Y=m_Y-25;
            break;
        }
    }
}
void heroplane::setPosition(int x, int y){
m_X=x;
m_Y=y;
m_Rect.moveTo(m_X,m_Y);
}
